﻿/*
 * This software is the confidential and proprietary
 * information of NetBay
 * Such confidential information should not be disclosed
 * NetBay copyright(c) 2010
 */

#region Using
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
#endregion

namespace NetBay.Core.BusinessEntities
{
    [DataContract]
    public class ReturnBoolean : ReturnValue<bool>
    {
        #region Init/Constructor
        /// <summary>
        /// Default constructor 
        /// </summary>
        public ReturnBoolean()
        {
        }

        /// <summary>
        /// Usefull constructor
        /// </summary>
        /// <param name="p_oValue">The value to store</param>
        public ReturnBoolean(bool p_oValue)
            : base(p_oValue)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Folder"/> class for error usages
        /// </summary>
        /// <param name="errorMessage">The error message.</param>
        /// <param name="applicationException">The application exception.</param>
        public ReturnBoolean(string errorMessage, Exception applicationException = null)
            : base(errorMessage, applicationException)
        {
        }
        #endregion
    }

    [DataContract]
    public class ReturnString : ReturnValue<string>
    {
        #region Init/Constructor
        /// <summary>
        /// Default constructor 
        /// </summary>
        public ReturnString()
        {
        }

        /// <summary>
        /// Usefull constructor
        /// </summary>
        /// <param name="p_oValue">The value to store</param>
        public ReturnString(string p_oValue)
            : base(p_oValue)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Folder"/> class for error usages
        /// </summary>
        /// <param name="errorMessage">The error message.</param>
        /// <param name="applicationException">The application exception.</param>
        public ReturnString(string errorMessage, Exception applicationException = null)
            : base(errorMessage, applicationException)
        {
        }
        #endregion
    }

    [DataContract]
    public class ReturnLong : ReturnValue<long>
    {
        #region Init/Constructor
        /// <summary>
        /// Default constructor 
        /// </summary>
        public ReturnLong()
        {
        }

        /// <summary>
        /// Usefull constructor
        /// </summary>
        /// <param name="p_oValue">The value to store</param>
        public ReturnLong(long p_oValue)
            : base(p_oValue)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Folder"/> class for error usages
        /// </summary>
        /// <param name="errorMessage">The error message.</param>
        /// <param name="applicationException">The application exception.</param>
        public ReturnLong(string errorMessage, Exception applicationException = null)
            : base(errorMessage, applicationException)
        {
        }
        #endregion
    }

    [DataContract]
    public class ReturnDictionarySzSz : ReturnValue<Dictionary<string, string>>
    {
        #region Init/Constructor
        /// <summary>
        /// Default constructor 
        /// </summary>
        public ReturnDictionarySzSz()
        {
        }

        /// <summary>
        /// Usefull constructor
        /// </summary>
        /// <param name="p_oValue">The value to store</param>
        public ReturnDictionarySzSz(Dictionary<string, string> p_oValue)
            : base(p_oValue)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Folder"/> class for error usages
        /// </summary>
        /// <param name="errorMessage">The error message.</param>
        /// <param name="applicationException">The application exception.</param>
        public ReturnDictionarySzSz(string errorMessage, Exception applicationException = null)
            : base(errorMessage, applicationException)
        {
        }
        #endregion
    }

    [DataContract]
    public class ReturnByte : ReturnValue<byte[]>
    {
        #region Init/Constructor
        /// <summary>
        /// Default constructor 
        /// </summary>
        public ReturnByte()
        {
        }

        /// <summary>
        /// Usefull constructor
        /// </summary>
        /// <param name="p_oValue">The value to store</param>
        public ReturnByte(byte[] p_oValue)
            : base(p_oValue)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Folder"/> class for error usages
        /// </summary>
        /// <param name="errorMessage">The error message.</param>
        /// <param name="applicationException">The application exception.</param>
        public ReturnByte(string errorMessage, Exception applicationException = null)
            : base(errorMessage, applicationException)
        {
        }
        #endregion
    }

    [DataContract]
    public class ReturnDoubleValue : ReturnValue<byte[]>
    {
        #region Init/Constructor
        /// <summary>
        /// Default constructor 
        /// </summary>
        public ReturnDoubleValue()
        {
        }


        private int m_iSecondValue;
        [DataMember]
        public int SecondValue
        {
            get { return m_iSecondValue; }
            set { m_iSecondValue = value; }
        }

        /// <summary>
        /// Usefull constructor
        /// </summary>
        /// <param name="p_oValue">The value to store</param>
        public ReturnDoubleValue(byte[] p_oValue, int p_iSecondValue)
            : base(p_oValue)
        {
            m_iSecondValue = p_iSecondValue;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Folder"/> class for error usages
        /// </summary>
        /// <param name="errorMessage">The error message.</param>
        /// <param name="applicationException">The application exception.</param>
        public ReturnDoubleValue(string errorMessage, Exception applicationException = null)
            : base(errorMessage, applicationException)
        {
        }
        #endregion
    }

    [DataContract]
    public class ReturnValue<T> : ReturnObject
    {
        private T m_oValue = default(T);

        [DataMember]
        public T Value
        {
            get { return m_oValue; }
            set { m_oValue = value; }
        }

        #region Init/Constructor
        /// <summary>
        /// Default constructor 
        /// </summary>
        public ReturnValue()
        {
        }

        /// <summary>
        /// Usefull constructor
        /// </summary>
        /// <param name="p_oValue">value to store</param>
        public ReturnValue(T p_oValue)
        {
            Value = p_oValue;
            IsValid = true;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Folder"/> class for error usages
        /// </summary>
        /// <param name="errorMessage">The error message.</param>
        /// <param name="applicationException">The application exception.</param>
        public ReturnValue(string errorMessage, Exception applicationException = null)
            : base(errorMessage, applicationException)
        {
        }
        #endregion

        #region ToString
        /// <summary>
        /// Extend default description of class
        /// </summary>
        /// <returns>description of instance</returns>
        public override string ToString()
        {
            StringBuilder parameters = new StringBuilder("Value<", 4096);
            parameters.Append(Value); parameters.Append("> ");

            return parameters.ToString();
        }
        #endregion

    }
}
